{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "ee97b7ef",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2022-05-03T11:15:10.893174Z",
     "start_time": "2022-05-03T11:15:10.882204Z"
    }
   },
   "outputs": [],
   "source": [
    "import requests"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "85b5167f",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2022-05-03T11:15:16.951319Z",
     "start_time": "2022-05-03T11:15:16.771708Z"
    }
   },
   "outputs": [],
   "source": [
    "# 2. 请求的地址 url：https://restapi.amap.com/v3/geocode/geo?parameters\n",
    "geo_url = \"https://restapi.amap.com/v3/geocode/geo?parameters\"\n",
    "\n",
    "# 3. 请求方式：GET\n",
    "\n",
    "# 4. 请求参数\n",
    "payload = {\n",
    "    \"key\":\"682fce538eb09c02fe00d9268bf7f974\",\n",
    "    \"address\":\"广州市从化区中山大学南方学院\"\n",
    "}\n",
    "# 5. 发起请求\n",
    "r = requests.get(url = geo_url,params = payload)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "ab1ece57",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2022-05-03T11:15:37.543984Z",
     "start_time": "2022-05-03T11:15:37.511097Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Response [200]>"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "04b7538f",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2022-05-03T11:16:01.905042Z",
     "start_time": "2022-05-03T11:16:01.886091Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'status': '1',\n",
       " 'info': 'OK',\n",
       " 'infocode': '10000',\n",
       " 'count': '1',\n",
       " 'geocodes': [{'formatted_address': '广东省广州市从化区中山大学南方学院',\n",
       "   'country': '中国',\n",
       "   'province': '广东省',\n",
       "   'citycode': '020',\n",
       "   'city': '广州市',\n",
       "   'district': '从化区',\n",
       "   'township': [],\n",
       "   'neighborhood': {'name': [], 'type': []},\n",
       "   'building': {'name': [], 'type': []},\n",
       "   'adcode': '440117',\n",
       "   'street': [],\n",
       "   'number': [],\n",
       "   'location': '113.679287,23.632575',\n",
       "   'level': '兴趣点'}]}"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r.json()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "c70eaa39",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2022-05-03T11:16:17.887475Z",
     "start_time": "2022-05-03T11:16:17.867525Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'113.679287,23.632575'"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "广州南方学院_location = r.json()['geocodes'][0]['location']\n",
    "广州南方学院_location"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "b5fc66e7",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "02936706",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2022-05-03T11:11:45.964487Z",
     "start_time": "2022-05-03T11:11:45.790793Z"
    }
   },
   "outputs": [],
   "source": [
    "import requests"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "44c736a4",
   "metadata": {},
   "outputs": [],
   "source": [
    "around_url = ''"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  },
  "varInspector": {
   "cols": {
    "lenName": 16,
    "lenType": 16,
    "lenVar": 40
   },
   "kernels_config": {
    "python": {
     "delete_cmd_postfix": "",
     "delete_cmd_prefix": "del ",
     "library": "var_list.py",
     "varRefreshCmd": "print(var_dic_list())"
    },
    "r": {
     "delete_cmd_postfix": ") ",
     "delete_cmd_prefix": "rm(",
     "library": "var_list.r",
     "varRefreshCmd": "cat(var_dic_list()) "
    }
   },
   "types_to_exclude": [
    "module",
    "function",
    "builtin_function_or_method",
    "instance",
    "_Feature"
   ],
   "window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
